package com.club.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.club.entity.TActivity;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * 针对TActivity的Mapper
 * @author zhangfc
 * @date 2022/12/12 16:44
 */
public interface TActivityMapper extends BaseMapper<TActivity> {


    @Select("select t.*,c.club_number,c.club_name  from user_act_relation ua " +
            "left join t_activity t on ua.act_id = t.act_id left join t_club c on t.club_id = c.club_id " +
            "where ua.user_id = #{userId}")
    public List<Map<String,Object>> listByUserId(@Param("userId") int userId);


    @Select("SELECT\n" +
            "\ta.*,\n" +
            "\tc.club_number,\n" +
            "\tc.club_name,\n" +
            "\tu.username \n" +
            "FROM\n" +
            "\tt_activity a\n" +
            "\tLEFT JOIN t_club c ON a.club_id = c.club_id\n" +
            "\tLEFT JOIN sys_user u ON c.user_id = u.id \n" +
            "WHERE\n" +
            "\ta.act_id = #{actId}")
    public Map<String,Object> msgByActId(@Param("actId") int actId);

}
